package com.fesine.scheduler.jobs;

import com.fesine.scheduler.util.AnotherBean;
import com.fesine.scheduler.util.SecondBean;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/11/15 14:21
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/15 14:21
 */
public class FirstScheduledJob extends QuartzJobBean {

    private AnotherBean anotherBean;
    private SecondBean secondBean;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws
            JobExecutionException {
        System.out.println(new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(new Date()) +
                "，FirstScheduledJob 通过 JobDetailFactoryBean 调用，通过 " +
                "CronTriggerFactoryBean 触发");
        //这里就可以引用其他job处理类
        this.anotherBean.printAnotherMessage();
        this.secondBean.execute();
    }

    public void setAnotherBean(AnotherBean anotherBean) {
        this.anotherBean = anotherBean;
    }

    public void setSecondBean(SecondBean secondBean) {
        this.secondBean = secondBean;
    }
}
